<template>
	<view class="page">
		<view class="list">
			<view class="listX" v-for="(v, k) in listData" :key="k">
				<view class="listX_top">
					<view class="img">
						<image :src="v.head_img" mode="aspectFill"></image>
						
					</view>
					<view class="name">
						<view v-if="v.type == 1">匿名</view>
						<view v-else>{{v.user_nickname}}</view>
						<view>{{v.create_time}}</view>
					</view>
					<view class="starnum">
						<u-rate :count="count" v-model="v.star" active-color="#F5E131" inactive-color="#BFBFBF" inactive-icon="star-fill" :disabled="true" size="24" gutter="7"></u-rate>
					</view>
				</view>
				<view class="listX_bottom u-line-5">{{v.content}}</view>
			</view>
		</view>
		<view v-if="listData.length == 0" style="padding: 20rpx 0;">
			<u-empty  text="没有更多了" mode="list"></u-empty>
		</view>
		<view style="padding: 20rpx 0;">
			<u-loadmore v-if="last_page > 1" :status="status" :icon-type="iconType" :load-text="loadText" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				count: 5,
				value: 4,
				listData: [],
				last_page: 1,
				page: 1,
				refresh: false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				}
			}
		},
		onShow() {
			uni.showLoading({
				title: '加载中'
			})
			this.page = 1
			this.refresh = true
			this.evaluateInfo()
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.refresh = true
			this.evaluateInfo()
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			this.refresh = false
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.evaluateInfo()
			}, 500)
		},
		methods: {
		      // 获取评价列表
		      evaluateInfo() {
		      	this.$api.post(global.apiUrls.getMyEvaluate, {
		      		page: this.page
		      	}).then(res => {
		      		// console.log(res)
		      		uni.hideLoading()
		      		uni.stopPullDownRefresh()
		      		if (res.data.code == 1) {
		      			this.last_page = res.data.data.last_page
		      			if (this.refresh) {
		      				this.listData = res.data.data
							this.refresh = false
		      			} else {
		      				this.listData = this.listData.concat(res.data.data)
		      
		      			}
		      		} else {
		      			this.$message.info(res.data.msg)
		      		}
		      	})
		      },
		}
	}
</script>

<style lang="scss" scoped>
  .page{
    min-height: 100vh;
    background-color: #FFFFFF;
	color: #333333;
	.list {
		padding: 0 32rpx;
		.listX {
			padding: 32rpx 0;
			border-bottom: 1rpx solid #f2f2f1;
			.listX_top {
				display: flex;
				.img {
					width: 88rpx;
					margin-right: 24rpx;
					image {
						width: 88rpx;
						height: 88rpx;
						border-radius: 50%;
					}
				}
				.name{
					flex: 6;
					padding-top: 6rpx;
					view:first-child {
						font-size: 28rpx;
						color: #6B6F73;
						margin-bottom: 12rpx;
					}
					view:last-child {
						font-size: 24rpx;
						color: #BFBFBF;
					}
				}
				.starnum {
					padding-top: 14rpx;
					/deep/.uicon-star:before {
						color: #bfbfbf;
					}
				}
			}
			.listX_bottom {
				margin-top: 22rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 42rpx;
			}
		}
	}
  }
  
</style>
